package leetcode.code0739;

import java.util.Stack;

import leetcode.IDebug;

public class Solution739 implements IDebug {

	public int[] dailyTemperatures(int[] temperatures) {
		int len = temperatures.length;
		int[] ans = new int[len];
		Stack<Integer> s = new Stack<>();
		for (int i = 0; i < len; i++) {
			while (!s.isEmpty() && temperatures[s.peek()] < temperatures[i]) {
				int index = s.pop();
				ans[index] = i - index;
			}
			s.add(i);
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution739 so = new Solution739();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
